// type Flatten<T extends any[]> = T extends (infer R)[] ? R extends any[] ? Flatten<R> : [R] : T;

// type FEmty<T extends any[]> = T extends [infer R, ...infer X] ? R : T;
// type Flatten<T extends any[], S extends any[] = []> = T extends [infer R, ...infer X]
//   ? [R extends any[] ? FEmty<R> : R, ...FEmty<X>]
//   : T;
// ===>>> 不懂
// S T接收 any[] 默认是 []
type Flatten<S extends any[], T extends any[] = []> = S extends [
  infer X,
  ...infer Y
]
  ? X extends any[]
    ? Flatten<[...X, ...Y], T>
    : Flatten<[...Y], [...T, X]>
  : T;

type FF = Flatten<[1, [2], [5]]>;
